package com.iflytek.controller;

import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import com.iflytek.entity.Student;
import com.iflytek.service.ISignInRecordService;

import java.util.HashMap;
import java.util.Map;
import java.util.Objects;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author 周超
 * @since 2025-05-29
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/sign-in/record")
public class SignInRecordController {
    private final ISignInRecordService signInRecordService;

    @PostMapping
    public Map<String, Object> recordSignIn(@RequestPart("file") MultipartFile file) {
        // 这里可以添加处理签到记录的逻辑
        Map<String, Object> result = new HashMap<>();
        Student student = signInRecordService.recordSignIn(file);
        if (!Objects.isNull(student)) {
            result.put("code", 200);
            result.put("name", student.getName());
            result.put("message", "签到成功");
        } else {
            result.put("code", 500);
            result.put("message", "签到失败");
        }
        return result;
    }
}
